﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Option.Master" AutoEventWireup="true"
    CodeBehind="SelectGroupUser.aspx.cs" Inherits="MsgCenter.Web.Pages.UserGroup.SelectGroupUser" %>

<asp:Content ID="Content1" ContentPlaceHolderID="headContent" runat="server">
    <script type="text/javascript" src="<%=ResolveClientUrl("~/JavaScript/FirePlat/assets/js/jqGrid/jquery.jqGrid.min.js") %>"></script>
    <script type="text/javascript" src="<%=ResolveClientUrl("~/JavaScript/FirePlat/assets/js/jqGrid/i18n/grid.locale-cn.js") %>"></script>
    <script type="text/javascript" src="<%=ResolveClientUrl("~/JavaScript/FirePlat/assets/js/jqGrid/myJqgrid.js") %>"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mailContent" runat="server">
    <div class="row">
        <div class="col-xs-10">
            <table id="grid-table">
            </table>
        </div>
        <div class="col-xs-2">
            <div class="widget-box">
                <div class="widget-header header-color-blue2">
                    <h4 class="lighter smaller">
                        功能操作</h4>
                </div>
                <div class="widget-body">
                    <div class="widget-main padding-8" style="height: 415px">
                        <br />
                        <br />
                        <div class="row">
                            <div class="col-xs-12">
                                <button class="btn btn-sm btn-primary" onclick="return SelectUser();">
                                    <i class="icon-edit bigger-110"></i>按用户选择 <i class="icon-arrow-right icon-on-right">
                                    </i>
                                </button>
                                <br />
                                <br />
                                <br />
                                <br />
                                <br />
                                <br />
                                <button class="btn btn-sm btn-success" onclick="return SelectUserAdd();">
                                    <i class="icon-ok bigger-110"></i>添加人员 <i class="icon-arrow-right icon-on-right">
                                    </i>
                                </button>
                                <br />
                                <br />
                                <br />
                                <br />
                                <br />
                                <br />
                                <button class="btn btn-danger btn-block" onclick="return CloseBox();">
                                    关闭窗体</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript">
        var gridTableID = 'grid-table';
        jQuery(function ($) {
            var colNames = ['GroupID', '分组名称', '用户ID', '姓名', '是否删除', '创建日期']; //, ' '
            var colModel = [
				{ name: 'GroupID', index: 'GroupID', width: 10, editable: false, hidden: true },
				{ name: 'GroupName', index: 'GroupName', width: 30, editable: false, stype: 'text', searchoptions: { sopt: ['eq', 'ne', 'cn', 'nc']} },
				{ name: 'UserID', index: 'UserID', width: 60, editable: false, stype: 'text', sortable: false, hidden: true },
				{ name: 'UserName', index: 'UserName', width: 60, editable: false, stype: 'text', sortable: false, searchoptions: { sopt: ['eq', 'ne', 'cn', 'nc']} },
                { name: 'IsDelete', index: 'IsDelete', search: false, width: 40, editable: false,
                    formatter: function (value) {
                        if (value.toString() == "True") {
                            return "是";
                        }
                        else {
                            return "否";
                        }
                    }
                },
				{ name: 'CreateDate', index: 'CreateDate', width: 30, editable: false, formatter: "date", formatoptions: { srcformat: 'Y-m-d H:i:s', newformat: 'Y-m-d' }, stype: 'text', searchoptions: { sopt: ['eq', 'ne', 'lt', 'le', 'gt', 'ge'], dataInit: GridSelectDatePick} }
			];
            var dfop =
            {
                rownumbers: true,
                GridID: gridTableID,
                GridPagerID: null,
                Url: "../../Handlers/Handler_UserGroup.ashx?method=GetGroupAllList",
                ColNames: colNames,
                ColModel: colModel,
                Caption: "分组列表",
                SortName: "CreateDate",
                Height: 355,
                OndblClickRow: Look
            };
            showJqGrid(dfop);
        });
        function Look() {
            var id = $("#" + gridTableID).getGridParam("selrow");
            if (id) {
                var model = $("#" + gridTableID).jqGrid('getRowData', id);
                var o = {
                    title: "分组查看",
                    href: "Option.aspx?type=Look&Guid=" + model.GroupID
                };
                showColorbox(o);
            }
        }
        function SelectUserAdd() {
            var ids = $('#' + gridTableID).jqGrid('getGridParam', 'selarrrow');
            if (ids != "") {
                var userid = "";
                var username = "";
                for (var i = 0; i < ids.length; i++) {
                    var rowData = $('#' + gridTableID).jqGrid('getRowData', ids[i]);
                    if (username == "") {
                        username = rowData.UserName;
                        userid = rowData.UserID;
                    }
                    else {
                        username = username + "," + rowData.UserName;
                        userid = userid + "," + rowData.UserID;
                    }
                }

                var usernames = username.split(',');
                var userids = userid.split(',');
                var selectUser = "";
                for (var len = 0; len < usernames.length; len++) {
                    if (selectUser == "") {
                        selectUser = usernames[len] + "&" + userids[len];
                    }
                    else {
                        selectUser = selectUser + "," + usernames[len] + "&" + userids[len];
                    }
                }
                parent.SetSelectUser(username, selectUser);
                CloseBox();
            }
            else {
                showDialogMessage("请先选择接收人员!");
            }
            return false;
        }
        function SelectUser() {
            window.location = "../User/SelectUser.aspx";
            return false;
        }
        function CloseBox() {
            parent.CBClose();
        }
    </script>
</asp:Content>
